The effect is achieved by moving odd-numbered lines from right to left and even-numbered lines from left to right. For odd-numbered lines (with an index j), the ((j + i) % 2 == 0) condition is satisfied. In this case, the line width is set to i, resulting in the line moving from left to right. For even-numbered lines, the ((j + i) % 2 == 0) condition is not satisfied. The line width is set to $(tput cols) - i, causing the line to move from right to left. This alternating direction of movement creates a twisted visual effect as the lines appear to move in opposite directions. The code runs in a continuous loop, repeatedly updating the lines with changing background colors. There is a slight pause of 0.05 seconds between each iteration to control the speed of the animation.
This one-liner fills the screen with randomly colored lines.
apt install toilet toilet-fonts # replace 'tput setaf 1' with 'tput setaf 9' to change color
Generates a TV noise alike output in the terminal. Can be combined with https://www.commandlinefu.com/commands/view/9728/make-some-powerful-pink-noise
You will see it on the corner of your running terminal. Show Sample Output
Creates a line seperator that will be the width of your window. Show Sample Output
A function for retrieving and displaying a list of synonyms for a German word or phrase. Show Sample Output
tput setaf 1 && tput rev && seq -ws "___|" 81|fold -69|tr "0-9" "_" && tput sgr0
# (brick wall)
Replace the underscore with any other character. e.g. + or - or =
Here is an alternative that support unicodes, using echo:
It is using the \c flag, meaning no new line for the echo option -e.
You can replace the = with any unicode character.
Or to do the same into a PHP bash script:
shell = system("tput cols");
for( $i= 0 ; $i < $shell ; $i++ ){ echo "█"; }
Show Sample Output
This will use tput to place the command (date %T in this case) in the upper right corner of the terminal
Unlike other methods that use pipes and exec software like tr or sed or subshells, this is an extremely fast way to print a line and will always be able to detect the terminal width or else defaults to 80. It uses bash builtins for printf and echo and works with printf that supports the non-POSIX `-v` option to store result to var instead of printing to stdout.
Here it is in a function that lets you change the line character to use and the length with args, it also supports color escape sequences with the echo -e option.
function L() { local l=; builtin printf -vl "%${2:-${COLUMNS:-`tput cols 2>&-||echo 80`}}s\n" && echo -e "${l// /${1:-=}}"; }
With color:
L "`tput setaf 3`="
1. Use printf to store n space chars followed by a newline to an environment variable "l" where n is local environment variable from $COLUMNS if set, else it will use `tput cols` and if that fails it will default to 80.
2. If printf succeeds then echo `$l` that contains the chars, replacing all blank spaces with "-" (can be changed to anything you want).
From: http://www.askapache.com/linux/bash_profile-functions-advanced-shell.html http://www.askapache.com/linux/bash-power-prompt.html
Show Sample Output
Looks best in an 80x24 256-color terminal emulator.
Good for use in your ~/.bash_profile or a script. Show Sample Output
Don't want to open up an editor just to view a bunch of XML files in an easy to read format? Now you can do it from the comfort of your own command line! :-) This creates a new function, xmlpager, which shows an XML file in its entirety, but with the actual content (non-tag text) highlighted. It does this by setting the foreground to color #4 (red) after every tag and resets it before the next tag. (Hint: try `tput bold` as an alternative). I use 'xmlindent' to neatly reflow and indent the text, but, of course, that's optional. If you don't have xmlindent, just replace it with 'cat'. Additionally, this example shows piping into the optional 'less' pager; note the -r option which allows raw escape codes to be passed to the terminal. Show Sample Output
Show a full terminal line inverted with custom text.
hypnotizing pendulum
tput rmam
will disable line wrapping so that long lines are truncated to width of the terminal ($COLUMNS).
tput smam
will re-enable wrapping.
I've always used tput in bash scripts but I guess it works on the command line too.
Doesn't work in all terminals.
See http://www.gnu.org/software/termutils/manual/termutils-2.0/html_chapter/tput_1.html
This bash one-liner will let you watch the tail end of a log file in real time.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: